package br.com.basili.mb;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.primefaces.context.RequestContext;

import br.com.basili.entity.Definition;
import br.com.basili.entity.Generality;
import br.com.basili.entity.Metric;
import br.com.basili.entity.Question;
import br.com.basili.entity.Reality;
import br.com.basili.entity.Process;

@ViewScoped
@ManagedBean
public class DefenitionMB
{
	private Definition definition;
	
	private List<Metric> listaMetricas;
	
	private Process[] process;
	
	private Reality[] reality;
	
	private Generality[] generality;
	
	private String metricName;
	
	private Question question;
	
	public DefenitionMB() {
		process = Process.values();
		reality = Reality.values();
		generality = Generality.values();
		
		definition = new Definition();
		listaMetricas = new ArrayList<Metric>();
	}
	
	public void adicionaMetrica()
	{
		Metric m = new Metric();
		m.setDescription(metricName);
		
		listaMetricas.add(m);
	}
	
	public void preparaQuestions( Metric m )
	{
		RequestContext context = RequestContext.getCurrentInstance();
		question = new Question();
		question.setMetric(m);
		context.execute("questions.show()");
	}

	public Definition getDefinition() {
		return definition;
	}

	public void setDefinition(Definition definition) {
		this.definition = definition;
	}

	public Process[] getProcess() {
		return process;
	}

	public void setProcess(Process[] process) {
		this.process = process;
	}

	public Reality[] getReality() {
		return reality;
	}

	public void setReality(Reality[] reality) {
		this.reality = reality;
	}

	public Generality[] getGenerality() {
		return generality;
	}

	public void setGenerality(Generality[] generality) {
		this.generality = generality;
	}

	public String getMetricName() {
		return metricName;
	}

	public void setMetricName(String metricName) {
		this.metricName = metricName;
	}

	public List<Metric> getListaMetricas() {
		return listaMetricas;
	}

	public void setListaMetricas(List<Metric> listaMetricas) {
		this.listaMetricas = listaMetricas;
	}

	public Question getQuestion() {
		return question;
	}

	public void setQuestion(Question question) {
		this.question = question;
	}
	
}